Skip to content

docs: add extraction guide for sovereign_debt_py into its own repo#5

Merged
zachessesjohnson merged 2 commits intomainfrom
copilot/extract-sovereign-debt-py
Mar 9, 2026
Merged

docs: add extraction guide for sovereign_debt_py into its own repo#5
zachessesjohnson merged 2 commits intomainfrom
copilot/extract-sovereign-debt-py

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

sovereign_debt_py is a self-contained pure-Python sub-project inside this repo (sovereign_debt_py/ with its own pyproject.toml) that mirrors sovereign_debt_xl's analytic functions without PyXLL. This PR adds documentation on how to move it into a standalone GitHub repository.

Changes

  • docs/extract-sovereign-debt-py.md — full extraction guide covering:

    • Current subtree layout (two-level nesting: sovereign_debt_py/sovereign_debt_py/)
    • Option A — history-preserving via git subtree split (built-in) or git filter-repo (pip-installable, faster)
    • Option B — clean-start copy (git init -b main + push)
    • Post-extraction dependency wiring in pyproject.toml: git URL, PyPI, or submodule
    • Optional refactor pattern to have sovereign_debt_xl delegate to sovereign_debt_py rather than re-implementing logic
    • Removing the embedded subtree once it's an external dep
    • Ready-to-paste .github/workflows/pytest.yml for the new repo; notes on what (if anything) changes in sovereign_debt_xl's CI
    • Quick-reference checklist
  • README.md — adds ToC entry and a short section at the bottom linking to the guide

Key design note

The two packages currently share no import relationshipsovereign_debt_xl does not import from sovereign_debt_py. The guide covers the optional consolidation step for teams that want to eliminate the duplication after extraction.

Original prompt

Create a pull request that documents and/or implements the extraction of the sovereign_debt_py package/module from this repository into its own standalone GitHub repository.

Requirements:

  • Determine where sovereign_debt_py currently lives in zachessesjohnson/sovereign_debt_xl (folder path, whether it’s a package, submodule, or just a set of files).
  • Add clear, step-by-step instructions in-repo (e.g., in README.md or a new docs/ page) describing how to move sovereign_debt_py to its own repo.
  • If appropriate, add helper scripts or git commands (subtree split / filter-repo) instructions.
  • Ensure instructions cover:
    • preserving git history (preferred)
    • moving without history (simple copy)
    • updating imports in this repo to use the new repo (e.g., dependency via pip install git+https, PyPI later, or submodule)
    • CI/test updates after the move
  • Keep changes minimal and focused on documentation unless code changes are necessary.

Repository: zachessesjohnson/sovereign_debt_xl
Base branch: main

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Let's do option 2

zachessesjohnson/sovereign_debt_xl

Assistant: I’m paused waiting for you to accept/deny the pending repository update request in the dialog—once you respond, I can continue and set up the GitHub Actions pytest workflow.

User: @copilot Accepted Confirmation: Are you sure?

Assistant: I can’t directly write the workflow file into zachessesjohnson/sovereign_debt_xl from here (permission is blocked for the integration), but you can add it in under a minute in the GitHub web UI.

Create this file in your repo:

  • Path: .github/workflows/pytest.yml

Paste this content:

name: pytest

on:
  push:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12"]

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install -U pip
          if [ -f requirements.txt ]; then
            pip install -r requirements.txt
          else
            pip install numpy pandas scipy statsmodels scikit-learn pytest
          fi

      - name: Run tests
        run: |
          pytest -q

How to add it on GitHub.com

  1. Go to your repo → Add fileCreate new file
  2. In the filename box, type: .github/workflows/pytest.yml
  3. Paste the YAML above
  4. Commit to main (or to your branch and open a PR)

Confirm it ran

After committing:

  • Click the Actions tab → you should see a workflow run triggered for that commit/PR.

If you tell me what your default branch is (main vs something else) and whether you’re using a requirements.txt, I can adjust the workflow accordingly.

User: How do I change the settings so you can access it? This would make everything a lot easier

Assistant: You generally can’t “flip a repo setting” to make this Copilot chat integration write to your repo. The 403 Resource not accessible by integration error usually means the GitHub App/token backing this session doesn’t have write permission to repository contents, or it’s not allowed to access that repo due to org/app policy. That’s controlled by the app installation/permissions, not a normal repo checkbox.

That said, here are the realistic ways to make it work—depending on what you’re using.

Option A: Use a Pull Request tool flow (best when supported)

If your environment supports it, I can open a PR via an agent tool—but only if you explicitly ask “open a PR” and I have repo access. If it still fails, it’s the same underlying permission issue.

Option B: Install/authorize the correct GitHub App (what usually fixes it)

You (or an org admin) would need to:

  1. Go to GitHub Settings → Applications → Installed GitHub Apps
  2. Find the app that’s powering this integration (often “GitHub Copilot” / “Copilot” / the specific integration name shown there)
  3. Ensure it’s installed for your account/org and has access to the repository:
    • Repository access: All repositories or select sovereign_debt_xl
  4. Ensure the app has Contents: Read & write permission (needed to create/update files)

If you’re in an organization, there may also be:

  • an organization policy restricting GitHub Apps
  • a requirement for org admin approval of the app

Option C: Use a PAT locally (most reliable)

If you’re willing to run one command locally, you can give yourself a workflow where I generate patches and you apply them, or you push via git.

  • Create a Personal Access Token (classic) with repo scope (private) or public_repo (public)
  • Use it with git push from your machine

I can guide you through the exact commands, but I...

This pull request was created from Copilot chat.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…tion guide

Co-authored-by: zachessesjohnson <168567202+zachessesjohnson@users.noreply.github.com>
Copilot AI changed the title [WIP] Document and implement extraction of sovereign_debt_py module docs: add extraction guide for sovereign_debt_py into its own repo Mar 9, 2026
@zachessesjohnson zachessesjohnson marked this pull request as ready for review March 9, 2026 20:30
Copilot AI review requested due to automatic review settings March 9, 2026 20:30
@zachessesjohnson zachessesjohnson merged commit 6bfb626 into main Mar 9, 2026
4 checks passed
@zachessesjohnson zachessesjohnson deleted the copilot/extract-sovereign-debt-py branch March 9, 2026 20:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds repository documentation describing how to extract the sovereign_debt_py pure-Python subproject into a standalone GitHub repository, and links that guide from the main README.

Changes:

  • Added docs/extract-sovereign-debt-py.md with step-by-step extraction options (history-preserving and clean-copy) plus post-extraction wiring/CI notes.
  • Updated README.md ToC and added a short section linking to the extraction guide.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docs/extract-sovereign-debt-py.md New extraction guide documenting subtree/filter-repo/copy approaches and post-extraction dependency/CI steps.
README.md Adds a ToC entry and a link to the new extraction guide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +191 to +195
from sovereign_debt_py.averaging import xl_weighted_average

@xl_func(...)
def xl_weighted_average(values, weights):
return xl_weighted_average(values, weights)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the "After" example, the imported xl_weighted_average name is immediately redefined by the wrapper function, so return xl_weighted_average(...) will recursively call itself rather than delegating to sovereign_debt_py. Use an alias import (e.g., from sovereign_debt_py.averaging import xl_weighted_average as py_weighted_average) or import the module and qualify the call to avoid shadowing.

Suggested change
from sovereign_debt_py.averaging import xl_weighted_average
@xl_func(...)
def xl_weighted_average(values, weights):
return xl_weighted_average(values, weights)
from sovereign_debt_py.averaging import xl_weighted_average as py_weighted_average
@xl_func(...)
def xl_weighted_average(values, weights):
return py_weighted_average(values, weights)

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +51
```bash
# git ≥ 1.7.11 ships subtree support built-in — no extra install needed
git --version
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prerequisite note claims git subtree is "built-in" for git ≥ 1.7.11, but git subtree is a separate contrib script and may not be present in some git installations even if the version is new enough. Consider updating this to instruct users to run git subtree --help (or git subtree), and if missing, install/enable it (or use the git filter-repo path).

Copilot uses AI. Check for mistakes.
Comment on lines +119 to +127
# 3. Initialise a fresh git repo and make the first commit.
git init -b main
git add .
git commit -m "Initial commit: extracted from sovereign_debt_xl"

# 4. Push to the new repository.
git remote add origin https://github.com/zachessesjohnson/sovereign_debt_py.git
git branch -M main
git push -u origin main
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git init -b main requires relatively recent Git (2.28+). Since the guide earlier implies older git versions may be fine, this step can fail on older environments. Using plain git init and relying on the existing git branch -M main step avoids the version dependency (and also removes the redundancy of setting main twice).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants